<template>
    <view class="container">
        <div class="border">
            <div class="border-content">
                <div style="height: 10px;"></div>
                <!-- <div class="top-line">
                    <div class="line"></div>
                    <div style="width: 10px;"></div>
                    <div style="color: #1A512C;" v-show="indent == '维保'">派发维保工单</div>
                    <div style="color: #1A512C;" v-show="indent == '巡检'">派发巡检工单</div>
                    <div style="color: #1A512C;" v-show="indent == '知识库'">考试编辑</div>
                </div> -->
                <div class="card">
                    <div style="width: 90%;margin-left: 5%;">
                        <div style="height: 10px;"></div>
                        <div style="font-size: 18px;font-weight: 500;">基础信息</div>
                        <div style="height: 10px;"></div>
                        <u-line color="#f1f1f1"></u-line>
                        <div style="height: 10px;"></div>
                        <div class="newFlex">
                            <div>日期</div>
                            <div>{{ date }}</div>
                        </div>
                        <div style="height: 15px;"></div>
                        <div class="newFlex">
                            <div>时间</div>
                            <div>{{ time }}</div>
                        </div>
                        <div style="height: 15px;"></div>
                    </div>
                </div>
                <div style="height: 10px;"></div>
                <div class="card" v-if="indent == '维保'">
                    <div style="width: 90%;margin-left: 5%;">
                        <div style="height: 10px;"></div>
                        <div style="font-size: 18px;font-weight: 500;">派发维保</div>
                        <div style="height: 10px;"></div>
                        <u-line color="#f1f1f1"></u-line>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>维保类型</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindMainType" :value="index" :range="mainTypeList">
                                    <input style="height: 42px;" type="text" v-model="disForm.repairMaintainType"
                                        placeholder="请选择维保类型" disabled>
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>设备名称</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindDeviceChange" :value="index" :range="deList">
                                    <input style="height: 42px;" type="text" v-model="disForm.deviceName"
                                        placeholder="请选择设备" disabled>
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>设备编号</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" v-model="disForm.deviceNo" disabled type="text">
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>所属部门</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" v-model="disForm.deptName" disabled type="text">
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>紧急程度</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindDegree" :value="index" :range="degreeList">
                                    <input style="height: 42px;" v-model="disForm.emerDegree" placeholder="请选择紧急程度"
                                        disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>故障类型</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindBedChange" :value="index" :range="bed">
                                    <input style="height: 42px;" v-model="disForm.faultType" placeholder="请选择故障类型"
                                        disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>指定人员</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindUserChange" :value="index" :range="userlist">
                                    <input style="height: 42px;" v-model="disForm.userName" placeholder="请选择人员" disabled
                                        type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>设备状态</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="(event) => bindState(event)" :value="index" :range="stateArr">
                                    <input style="height: 42px;" disabled v-model="disForm.deviceSate" type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>任务描述</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" disabled v-model="disForm.taskDesc" type="text">
                            </div>
                        </div>
                    </div>
                    <div style="height: 20px;"></div>
                </div>
                <!-- <div v-if="indent != '知识库'">
                    <div class="form-flex">
                        <div style="width: 20%;color: #1A512C;font-weight: 500;">日期</div>
                        <div class="borders" style="width: 80%;">
                            <div style="height: 5rpx;"></div>
                            {{ date }}
                            <div style="height: 5rpx;"></div>

                        </div>
                    </div>
                    <div style="height: 10px;"></div>
                    <div class="form-flex">
                        <div style="width: 20%;color: #1A512C;font-weight: 500;">时间</div>
                        <div class="borders" style="width: 80%;">
                            <div style="height: 5rpx;"></div>
                            {{ time }}
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div>
                </div> -->
                <div style="height: 10px;"></div>
                <!-- 表单展示 -->
                <!-- <div v-show="indent == '维保'"> -->
                <!-- <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">维保类型</div>
                        </div>
                        <div class="borders" style="width: 80%;">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindMainType" :value="index" :range="mainTypeList">
                                <input type="text" v-model="disForm.repairMaintainType" placeholder="请选择维保类型" disabled>
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">设备名称</div>
                        </div>
                        <div class="borders" style="width: 80%;">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindDeviceChange" :value="index" :range="deList">
                                <input type="text" v-model="disForm.deviceName" placeholder="请选择设备" disabled>
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>

                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">设备编号</div>
                        </div>
                        <div class="borders" style="width: 80%;">
                            <input v-model="disForm.deviceNo" disabled type="text">
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">所属部门</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <input v-model="disForm.deptName" disabled type="text">
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">紧急程度</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindDegree" :value="index" :range="degreeList">
                                <input v-model="disForm.emerDegree" placeholder="请选择紧急程度" disabled type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">故障类型</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindBedChange" :value="index" :range="bed">
                                <input v-model="disForm.faultType" placeholder="请选择故障类型" disabled type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">指定人员</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindUserChange" :value="index" :range="userlist">
                                <input v-model="disForm.userName" placeholder="请选择人员" disabled type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">设备状态</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height:5rpx"></div>
                            <picker @change="(event) => bindState(event)" :value="index" :range="stateArr">
                                <input disabled v-model="disForm.deviceSate" type="text">
                            </picker>
                            <div style="height:5rpx"></div>

                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">任务描述</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <u--textarea v-model="disForm.taskDesc"></u--textarea>
                        </div>
                    </div> -->
                <!-- </div> -->
                <div class="card" v-if="indent == '巡检'">
                    <div style="width: 90%;margin-left: 5%;">
                        <div style="height: 10px;"></div>
                        <div style="font-size: 18px;font-weight: 500;">派发巡检</div>
                        <div style="height: 10px;"></div>
                        <u-line color="#f1f1f1"></u-line>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>指定人员</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindUserChange" :value="index" :range="userlist">
                                    <input style="height: 42px;" v-model="repairForm.orderPersonName"
                                        placeholder="请选择人员" disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>巡检对象</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="bindXunChange" :value="index" :range="xunjian">
                                    <input style="height: 42px;" v-model="repairForm.inspectName" placeholder="请选择巡检对象"
                                        disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>巡检内容</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" v-model="repairForm.inspectContent" type="text">
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>任务描述</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" v-model="repairForm.taskDescription" disabled type="text">
                            </div>
                        </div>
                    </div>
                    <div style="height: 20px;"></div>
                </div>
                <!-- <div v-show="indent == '巡检'"> -->
                <!-- <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                        <div style="color: #1A512C;font-weight: 500;">派单类型</div>
                        </div>
                        <div class="borders" style="width: 80%;"><input type="text"></div>
                    </div>
                    <div style="height: 10px;"></div> -->
                <!-- <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">指定人员</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 80%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindUserChange" :value="index" :range="userlist">
                                <input v-model="repairForm.orderPersonName" placeholder="请选择人员" disabled type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">巡检对象</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 80%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="bindXunChange" :value="index" :range="xunjian">
                                <input v-model="repairForm.inspectName" placeholder="请选择巡检对象" disabled type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">巡检内容</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <input v-model="repairForm.inspectContent" type="text">
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">任务描述</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%"><u--textarea
                                v-model="repairForm.taskDescription"></u--textarea></div>
                    </div> -->
                <!-- </div> -->
                <div class="card" v-if="indent == '知识库'">
                    <div style="width: 90%;margin-left: 5%;">
                        <div style="height: 10px;"></div>
                        <div style="font-size: 18px;font-weight: 500;">编辑考试</div>
                        <div style="height: 10px;"></div>
                        <u-line color="#f1f1f1"></u-line>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>开始日期</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker mode="date" :value="date" :start="startDate" :end="endDate"
                                    @change="bindDateChange">
                                    <!-- {{ date }} -->
                                    <input style="height: 42px;" v-model="date" disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>结束日期</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker mode="date" :value="date" :start="startDate" :end="endDate"
                                    @change="bindDateChanges">
                                    <!-- {{ dates }} -->
                                    <input style="height: 42px;" v-model="dates" disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>开始时间</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
                                    <input style="height: 42px;" v-model="timeS" disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>结束时间</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChanges">
                                    <!-- {{ timeSS }} -->
                                    <input style="height: 42px;" v-model="timeSS" disabled type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>选择试卷</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="(event) => bindChangeBank(event)" :value="index" :range="banklist">
                                    <input style="height: 42px;" disabled v-model="exam.paperName" type="text">
                                </picker>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div>
                            <div>合格分数</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <input style="height: 42px;" v-model="exam.scoreLine" type="text">
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                        <div v-for="(item, index) in exam.safetyTrainDetailList">
                            <div>考试人员</div>
                            <div style="height: 15rpx;"></div>
                            <div class="borders">
                                <picker @change="(event) => bindChangeExam(event, index)" :value="index"
                                    :range="exUserList">
                                    <input style="height: 42px;" disabled v-model="item.taskPersonName" type="text">
                                </picker>
                            </div>
                            <div style="height: 10px;"></div>
                        </div>
                        <div style="text-align: center;" v-if="indent == '知识库'" @click="addPerson">新增考试人员</div>
                    </div>
                    <div style="height: 20px;"></div>
                </div>
                <!-- <div v-show="indent == '知识库'"> -->
                    <!-- <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">开始日期</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%;">
                            <div style="height: 5rpx;"></div>
                            <picker mode="date" :value="date" :start="startDate" :end="endDate"
                                @change="bindDateChange">
                                {{ date }}
                            </picker>

                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">结束日期</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%;">
                            <div style="height: 5rpx;"></div>
                            <picker mode="date" :value="date" :start="startDate" :end="endDate"
                                @change="bindDateChanges">
                                {{ dates }}
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">开始时间</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%;">
                            <div style="height: 5rpx;"></div>
                            <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
                                {{ timeS }}
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">结束时间</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%;">
                            <div style="height: 5rpx;"></div>
                            <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChanges">
                                {{ timeSS }}
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">选择试卷</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <picker @change="(event) => bindChangeBank(event)" :value="index" :range="banklist">
                                <input disabled v-model="exam.paperName" type="text">
                            </picker>
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div style="display: flex;align-items: center;">
                        <div style="display: flex;width: 20%;">
                            <div style="color: #1A512C;font-weight: 500;">合格分数</div>
                        </div>
                        <div style="width: 1%;"></div>
                        <div class="borders" style="width: 79%">
                            <div style="height: 5rpx;"></div>
                            <input v-model="exam.scoreLine" type="text">
                            <div style="height: 5rpx;"></div>
                        </div>
                    </div> -->
                    <!-- <div style="height: 10px;"></div>
                    <div v-for="(item, index) in exam.safetyTrainDetailList">
                        <div style="display: flex;align-items: center;">
                            <div style="display: flex;width: 20%;">
                                <div style="color: #1A512C;font-weight: 500;">考试人员</div>
                            </div>
                            <div style="width: 1%;"></div>
                            <div class="borders" style="width: 79%">
                                <div style="height: 5rpx;"></div>
                                <picker @change="(event) => bindChangeExam(event, index)" :value="index"
                                    :range="exUserList">
                                    <input disabled v-model="item.taskPersonName" type="text">
                                </picker>
                                <div style="height: 5rpx;"></div>
                            </div>
                        </div>
                        <div style="height: 10px;"></div>
                    </div> -->
                <!-- </div> -->
                <!-- <div style="height: 20px;"></div> -->
                <!-- <div style="text-align: center;" v-if="indent == '知识库'" @click="addPerson">新增考试人员</div> -->
                <!-- 按钮 -->
                <div style="height: 30rpx;"></div>
                <div class="footer">
                    <div class="button-footer" @click="submitInfo" v-show="indent != '知识库'">派发</div>
                    <div v-if="indent == '知识库'" class="button-footer" @click="startExam">开始考试</div>
                </div>
                <div style="height: 30rpx;"></div>
            </div>
        </div>
    </view>
</template>
<script>
import { updateExam, bankList, knoewDetail, addDisMain, deviceList, typeList, detail, getUser, inspect, Addinspect, postExam, choosePerson } from '../api/api.js';
export default {
    data() {
        const currentDate = this.getDate({
            format: true
        })
        return {
            ordTypeList: ['自派单', '手工单'],
            ordType: '',
            date: currentDate,
            dates: currentDate,
            time: '',
            //维保
            disForm: {
                deptId: '',
                deptName: '',
                userId: '',
                userName: '',
                deviceId: '',
                deviceNo: '',
                deviceName: '',
                deviceSate: '',
                launchTime: '',
                repairMaintainType: '',
                emerDegree: '',
                faultType: '',
                taskDesc: '',
            },
            //巡检
            repairForm: {
                orderPersonId: '',
                orderPersonName: '',
                inspectId: '',
                inspectName: '',
                inspectContent: '',
                taskDescription: '',
            },
            indent: '',
            deList: [],//设备列表
            deSeaList: [],//设备搜索
            mainTypeList: ['维修', '保养'],
            degreeList: ['一般紧急', '很紧急', '非常紧急'],
            stateArr: ['正常', '停用'],
            bed: [],
            seaBen: [],
            userlist: [],
            seaUserlist: [],
            xunjian: [],
            seaXunjian: [],
            timeS: '请选择开始时间',
            timeSS: '请选择结束时间',
            exUserList: [],
            seaExUserList: [],
            //知识库
            exam: {
                safetyTrainDetailList: [
                    {
                        taskPersonId: '',
                        taskPersonName: ''
                    }
                ],
                paperId: '',
                paperName: '',
                scoreLine: '',
                startTime: '',
                endTime: '',

            },
            flagId: '',
            editInfo: {},
            banklist: [],
            seaBanlist: []
        }
    },
    methods: {
        cancelPage() {
            uni.navigateBack({
                delta: 1
            })
        },
        //选择设备zhaungta
        bindState(e) {
            const value = e.detail.value;
            console.log(value);
            this.disForm.deviceSate = this.stateArr[value];
            // console.log(this.disForm.deviceState,'this.disForm.deviceState');
        },
        //新增考试人员
        addPerson() {
            this.exam.safetyTrainDetailList.push(
                {
                    taskPersonId: '',
                    taskPersonName: ''
                }
            )
        },
        //试卷列表
        getBank() {
            bankList({}).then(res => {
                console.log(res.data, '---------------------------');
                this.seaBanlist = res.data.data;
                this.banklist = res.data.data.map((item) => item.paperName);
                console.log(this.banklist, '试卷列表--------->');
            })
        },
        //用户列表
        getUserList() {
            getUser({
                remark: '处理厂操作员'
            }).then(res => {
                console.log(res.data, 'userlist');
                this.userlist = res.data.data.map((item) => item.nickName);
                this.seaUserlist = res.data.data;
            })
        },
        //设备列表
        getDevice() {
            deviceList().then(res => {
                console.log(res.data.data, '设备列表');
                this.deList = res.data.data.map((item) => item.deviceName);
                this.deSeaList = res.data.data;
            })
        },
        //可考试人员
        getExperson() {
            choosePerson().then(res => {
                console.log(res.data, '人员');
                this.seaExUserList = res.data.data;
                this.exUserList = res.data.data.map((item) => item.nickName);
            })
        },
        //巡检对象列表
        insp() {
            inspect().then(res => {
                console.log(res.data, '巡检--------------------');
                this.xunjian = res.data.data.map((item) => item.inspectName);
                this.seaXunjian = res.data.data;
            })
        },
        //选择试卷
        bindChangeBank(e) {
            const value = e.detail.value;
            this.exam.paperName = this.seaBanlist[value].paperName;
            this.exam.paperId = this.seaBanlist[value].id;
        },
        //选择设备
        bindDeviceChange(e) {
            const value = e.detail.value;
            console.log(this.deSeaList[value]);
            this.disForm.deviceName = this.deSeaList[value].deviceName;
            this.disForm.deviceId = this.deSeaList[value].id;
            this.disForm.deptId = this.deSeaList[value].deptId;
            this.disForm.deptName = this.deSeaList[value].deptName;
            this.disForm.deviceNo = this.deSeaList[value].deviceNo;
            // this.disForm.deviceSate = this.deSeaList[value].deviceState;
            console.log(this.disForm.deviceSate, 'this.disForm.deviceSate');
        },
        //选择维保类型
        bindMainType(e) {
            const value = e.detail.value;
            this.disForm.repairMaintainType = this.mainTypeList[value];
        },
        //选择派单类型

        bindTypeState(e) {
            this.disForm.repairMaintainOrderState = e.detail.value;
            this.ordType = this.ordTypeList[e.detail.value];
        },
        //选择考试人员
        bindChangeExam(e, index) {
            const value = e.detail.value;
            console.log(value);
            this.exam.safetyTrainDetailList[index].taskPersonName = this.seaExUserList[value].nickName;
            this.exam.safetyTrainDetailList[index].taskPersonId = this.seaExUserList[value].userId;
            // this.seaExUserList
        },
        //选择紧急程度
        bindDegree(e) {
            const value = e.detail.value;
            this.disForm.emerDegree = this.degreeList[value];
        },
        //选择人员
        bindUserChange(e) {
            const value = e.detail.value;
            if (this.indent == '维保') {
                this.disForm.userName = this.seaUserlist[value].nickName;
                this.disForm.userId = this.seaUserlist[value].userId;
            } else if (this.indent == '巡检') {
                this.repairForm.orderPersonName = this.seaUserlist[value].nickName;
                this.repairForm.orderPersonId = this.seaUserlist[value].userId;
            }
        },
        //选择巡检点
        bindXunChange(e) {
            const value = e.detail.value;
            this.repairForm.inspectId = this.seaXunjian[value].id;
            this.repairForm.inspectName = this.seaXunjian[value].inspectName;
        },
        bindBedChange(e) {
            const value = e.detail.value;
            this.disForm.faultType = this.seaBen[value].constantName;
        },
        submitInfo() {
            if (this.indent == '维保') {
                this.disForm.launchTime = this.date + ' ' + this.time;
                this.disForm.deviceSate == '正常' ? this.disForm.deviceSate = 0 : this.disForm.deviceSate = 1;
                if (Object.values(this.disForm).some(value => value === null || value === undefined || value === '')) {
                    console.log(this.disForm, 'disForm');
                    uni.showToast({
                        title: '请输入完整',
                        icon: 'none'
                    })
                } else {
                    addDisMain(this.disForm).then(res => {
                        console.log(res.data, '派发维保任务');
                        if (res.data.code == 200) {
                            uni.showToast({
                                title: res.data.msg,
                                duration: 2000
                            });
                            this.clearForm();
                            setTimeout(() => {
                                uni.navigateBack({ delta: 1 });
                            }, 1000)
                        } else {
                            uni.showToast({
                                title: res.data.msg,
                                duration: 2000,
                                icon: 'none'
                            });
                        }
                    })
                }


            } else if (this.indent == '巡检') {
                // let result = this.repairForm.inspectName.split('(')[0];
                this.repairForm.inspectName = this.repairForm.inspectName.split('(')[0];
                console.log(this.repairForm, 'erpairForm');
                // 输出结果
                // console.log(result); // "鲁U10010"
                if (Object.values(this.repairForm).some(value => value === null || value === undefined || value === '')) {
                    uni.showToast({
                        title: '请输入完整',
                        icon: 'none'
                    })
                } else {
                    Addinspect(this.repairForm).then(res => {
                        console.log(res.data);
                        if (res.data.code == 200) {
                            uni.showToast({
                                title: res.data.msg,
                                duration: 2000
                            });
                            this.clearForm();
                            setTimeout(() => {
                                uni.navigateBack({ delta: 1 });
                            }, 1000)
                        } else {
                            uni.showToast({
                                title: res.data.msg,
                                duration: 2000,
                                icon: 'none'
                            });
                        }
                    })
                }


            } else {
                //知识库

            }
        },
        //开始考试
        startExam() {
            if (this.flagId == 1) {
                //编辑考试
                updateExam({
                    safetyTrainDetailList: this.exam.safetyTrainDetailList,
                    id: uni.getStorageSync('mainDetail').id,
                    startTime: this.date + ' ' + this.timeS + ':00',
                    endTime: this.dates + ' ' + this.timeSS + ':00',
                    scoreLine: this.exam.scoreLine,
                    paperName: this.exam.paperName,
                    paperId: this.exam.paperId,
                    completedPersonNum: this.editInfo.completedPersonNum,
                    passRate: this.editInfo.passRate,
                    answerRate: this.editInfo.answerRate,
                    predictPersonNum: this.editInfo.predictPersonNum
                }).then(res => {
                    console.log(res.data, '编辑考试');
                    if (res.data.code == 200) {
                        uni.showToast({
                            title: res.data.msg,
                            icon: 'success'
                        })
                        uni.navigateBack({ delta: 1 })
                        this.clearForm();
                    } else {
                        uni.showToast({
                            title: res.data.msg,
                            icon: 'none'
                        })
                    }
                })
            } else {
                const { paperId, paperName, safetyTrainDetailList } = this.exam;
                if (paperId && paperName && safetyTrainDetailList && this.timeS && this.timeSS) {
                    postExam({
                        safetyTrainDetailList: this.exam.safetyTrainDetailList,
                        startTime: this.date + ' ' + this.timeS + ':00',
                        endTime: this.dates + ' ' + this.timeSS + ':00',
                        scoreLine: this.exam.scoreLine,
                        paperName: this.exam.paperName,
                        paperId: this.exam.paperId
                    }).then(res => {
                        console.log(res.data, '开始考试');
                        if (res.data.code == 200) {
                            uni.showToast({
                                title: res.data.msg,
                                icon: 'success'
                            })
                            uni.navigateBack({ delta: 1 })
                            this.clearForm();
                        } else {
                            uni.showToast({
                                title: res.data.msg,
                                icon: 'none'
                            })
                        }
                    })
                } else {
                    uni.showToast({
                        title: '请输入完整',
                        icon: 'none'
                    })
                }

            }

        },
        cancel() {
            uni.navigateBack({ delta: 1 })
        },
        bindDateChange: function (e) { //选择日期
            this.date = e.detail.value
            console.log('date', this.date)
        }, bindDateChanges: function (e) { //选择日期
            this.dates = e.detail.value
            console.log('date', this.date)
        }, bindTimeChange: function (e) {
            this.timeS = e.detail.value
        }, bindTimeChanges: function (e) {
            this.timeSS = e.detail.value
        },
        getDate(type) { //年月日
            const date = new Date();
            // const date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day = date.getDate();

            if (type === 'start') {
                year = year - 60;
            } else if (type === 'end') {
                year = year + 2;
            }
            month = month > 9 ? month : '0' + month;
            day = day > 9 ? day : '0' + day;
            return `${year}-${month}-${day}`;
        },
        getTime() {
            const now = new Date();
            const hours = now.getHours();
            const minutes = now.getMinutes();
            // this.time = hours + ':' + minutes
        },
        clearForm() {
            this.disForm = {
                deptId: '',
                deptName: '',
                userId: '',
                userName: '',
                deviceId: '',
                deviceNo: '',
                deviceName: '',
                deviceSate: '',
                launchTime: '',
                repairMaintainType: '',
                emerDegree: '',
                faultType: '',
                taskDesc: '',
            };
            this.repairForm = {
                orderPersonId: '',
                orderPersonName: '',
                inspectId: '',
                inspectName: '',
                inspectContent: '',
                taskDescription: '',
            };
            this.exam = {
                safetyTrainDetailList: [
                    {
                        taskPersonId: '',
                        taskPersonName: ''
                    }
                ],
                paperId: 1,
                paperName: '1',
                scoreLine: '',
                startTime: '',
                endTime: '',
            };
        }
    },
    onShow() {
        this.indent = uni.getStorageSync('pageIndent');
        //设备列表/巡检列表/用户列表
        this.insp();
        this.getUserList();
        this.getDevice();

        if (this.indent == '维保') {
            uni.setNavigationBarTitle({
                title: '派发维保'
            });
        } else if (this.indent == '巡检') {
            uni.setNavigationBarTitle({
                title: '派发巡检'
            });
        } else if (this.indent == '知识库') {
            uni.setNavigationBarTitle({
                title: '考试编辑'
            });
            this.getExperson();
            this.getBank();
        }
        let now = new Date();
        let hours = now.getHours().toString().padStart(2, '0');
        let minutes = now.getMinutes().toString().padStart(2, '0');
        let seconds = now.getSeconds().toString().padStart(2, '0');
        let currentTime = `${hours}:${minutes}:${seconds}`;
        this.time = currentTime;
        this.getTime();
        //常用量
        typeList().then(res => {
            console.log(res);
            let id = res.data.data.find((item) => item.constantName == "故障类型");
            detail({ id: id.id }).then((res) => {
                console.log(res, "故障类型");
                this.bed = res.data.data.map((item) => item.constantName);
                this.seaBen = res.data.data;
            });
        })
    },
    onLoad(option) {
        console.log(option, 'option---------------');
        this.flagId = option.id;
        //如果为1则编辑
        if (this.flagId == 1) {
            let info = uni.getStorageSync('mainDetail');
            this.editInfo = uni.getStorageSync('mainDetail');
            this.exam = {
                paperId: info.paperId,
                paperName: info.paperName,
                scoreLine: info.scoreLine,
            }
            this.timeS = info.startTime.substring(11);
            this.timeSS = info.endTime.substring(11);
            this.date = info.startTime.split(' ')[0];
            this.dates = info.endTime.split(' ')[0];

            knoewDetail(info.id).then(res => {
                console.log(res.data);
                if (res.data.code == 200) {
                    let arr = res.data.data;
                    // console.log(arr,'arrss');
                    this.exam.safetyTrainDetailList = arr.map(item => ({
                        taskPersonId: item.taskPersonId,
                        taskPersonName: item.taskPersonName
                    }))
                    console.log(this.exam.safetyTrainDetailList, 'this.exam.safetyTrainDetailList');
                } else {
                    this.arr = [];
                }
            })
        }

    }
}
</script>
<style lang="scss">
.newFlex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.container {
    background: #f3f3f3;

    .border {
        border-radius: 10px;
        background: #f3f3f3;
        height: 100vh;
        overflow-y: scroll;

        .border-content {
            width: 90%;
            margin-left: 5%;
        }
    }
}

.card {
    background: #fff;
    border-radius: 10px;
}

.top-line {
    display: flex;
    align-items: center;
}

.line {
    background: #1A512C;
    width: 7rpx;
    height: 35rpx;
}

.maps {
    border: 2px solid #1A512C;
    overflow: hidden;
    border-radius: 10px;
}

.form-flex {
    display: flex;
    align-items: center;
    width: 100%;
}

.borders {
    border: 1px solid #000000;
    border-radius: 5px;
    text-align: center;
}

.border-max {
    border: 1px solid #1A512C;
    border-radius: 5px;
    text-align: center;
    width: 100%;
}

.borders-min {
    border: 1px solid #1A512C;
    border-radius: 5px;
    text-align: center;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.button-footer {
    width: 95%;
    margin-left: 2.5%;
    height: 50px;
    background: #000000;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: 500;
    border-radius: 10px;
}

.flex {
    display: flex;
    align-items: center;
}

.addIcon {
    border-radius: 50%;
    border: 1px solid #1A512C;
    font-weight: 500;
    width: 40rpx;
    height: 40rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
</style>